﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Week1.world.behavior
{
    /// <summary>
    /// Class contains only the data and helper methods to access the data. Main class that uses the data for rendering is DrawableBase.
    /// </summary>
    public class DrawableGlobalVar
    {
        #region world Transofrmations variables
        public int iInstanceCount;
        public Matrix[] oWorld;
        public Vector3[] oPosition;
        public Vector3[] oDirection;
        public float[] fAngleX;
        public float[] fRotateX;
        public player.Camera oCamera;
        private void initTransform(player.Camera camera, int instanceCount)
        {
            iInstanceCount = instanceCount;
            oCamera = camera;
            oWorld = new Matrix[iInstanceCount];
            oPosition = new Vector3[iInstanceCount];
            oDirection = new Vector3[iInstanceCount];
            fAngleX = new float[iInstanceCount];
            fRotateX = new float[iInstanceCount];
        }
        #endregion

        #region 3D model render variables
        public Model oModel;
        public string sModelName;
        public Effect oEffect;
        public DepthStencilState oDepthState;
        public RasterizerState oRasterState;
        private void initModelVars(string modelName, Effect effect)
        {
            sModelName = modelName;
            oEffect = effect;
        }
        #endregion

        #region states / trigger variables
        public bool[] bActive;
        private void initStateVars()
        {
            bActive = new bool[iInstanceCount];
        }
        #endregion

        #region behavior vars, object type, etc
        public enum ObjectType : int
        {
            neutral, tower, enemy, destination
        };
        public ObjectType iObjectType;
        const int MAXBEHAVIOR = 20;
        public world.behavior.BehaviorBase[] oBehavior;
        public int iBehaviourCount;
        public int[] iBehaviorHandler;
        private void initBehaviorBaseVars()
        {
            iObjectType = ObjectType.neutral;
            oBehavior = new BehaviorBase[MAXBEHAVIOR];
            iBehaviorHandler = new int[MAXBEHAVIOR];
            iBehaviourCount = 0;
        }
        #endregion

        #region debug variables
        public helper.DebugConsole oConsole;
        public VertexPositionColor[] oDebugRender;
        private void initDebugVars()
        {
            oConsole = null;
            oDebugRender = new VertexPositionColor[iInstanceCount * 4];
        }
        #endregion

        public DrawableGlobalVar(int instanceCount, string modelName, Effect effect, player.Camera camera)
        {
            initTransform(camera, instanceCount);
            initModelVars(modelName, effect);
            initStateVars();
            initBehaviorBaseVars();
            initDebugVars();
        }


    }

    public struct Path
    {
        public Vector3 start;
        public Vector3 end;
    };
}
